package com.neusoft.elm.controller;

import com.neusoft.elm.po.User;
import com.neusoft.elm.service.UserService;
import com.neusoft.elm.service.impl.UserServiceImpl;

import javax.servlet.http.HttpServletRequest;

public class UserController {
   UserService userService=new UserServiceImpl();

public Object saveUser(HttpServletRequest request)throws Exception{
    String userId = request.getParameter("userId");
    String password = request.getParameter("password");
    String username = request.getParameter("username");
    Integer userSex = Integer.valueOf(request.getParameter("userSex"));
    String userImg = request.getParameter("userImg");
    Integer delTag=Integer.valueOf(request.getParameter("delTag"));
    User user=new User(userId,password,username,userSex,userImg,0);
    int n = userService.saveUser(user);
    return n;
}
public Object getUserByIdByPass(HttpServletRequest request) throws Exception {
    String userId=request.getParameter("userId");
    String password = request.getParameter("password");
    User user=userService.getUserByIdByPass(userId,password);
    if (user!=null){
        request.getSession().setAttribute("user",user);
    }
    return user;
}
public Object getUserById(HttpServletRequest request)throws Exception{
    String userId = request.getParameter("userId");
    User user=userService.getUserById(userId);
    return user;


}


}
